//
//  SJZMineViewController.m
//  SJZBusiness
//
//  Created by 彭利民 on 2018/4/26.
//  Copyright © 2018年 bwton. All rights reserved.
//

#import "SJZMineViewController.h"
#import "SJZCommonGroup.h"
#import "SJZCommonItem.h"
#import "SJZCommonCell.h"
#import "SJZCommonArrowItem.h"
#import "SJZCommonSwitchItem.h"
#import "SJZCommonLabelItem.h"
#import "SJZRightImageItem.h"
#import "SJZMineHeaderView.h"

#import "SJZHexiaoSuccessViewController.h"
#import "SJZHexiaoFailureViewController.h"
#import "SJZSettingController.h"

@interface SJZMineViewController ()

@end

@implementation SJZMineViewController

- (void)viewDidLoad {
    [super viewDidLoad];

//    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"我的" style:UIBarButtonItemStylePlain target:self action:@selector(leftItemClick)];
    
//    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"消息" style:UIBarButtonItemStylePlain target:self action:@selector(rightItemClick)];
    
//    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"sjz_mine_rightMessage"] style:UIBarButtonItemStylePlain target:self action:@selector(rightItemClick)];
    
    self.title = @"我的";
    
    self.view.backgroundColor = [UIColor colorWithRed:246/255.0 green:246/255.0 blue:246/255.0 alpha:1];
    
    [self setupGroups];
    
    [self setUpTableViewHeader];
    self.edgesForExtendedLayout = UIRectEdgeNone;

}

- (void)setUpTableViewHeader
{
    UIView *header = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, 120 + 15 + 8)];
    
   
    
    SJZMineHeaderView *headerView = [[SJZMineHeaderView alloc] initWithFrame:CGRectMake(0, 8, kScreenWidth, 120)];
    
    [header addSubview:headerView];
 

    self.tableView.tableHeaderView = header;
}

- (void)leftItemClick
{
    NSLog(@"我的点击");
    
    SJZHexiaoSuccessViewController *hexiaoVc = [[SJZHexiaoSuccessViewController alloc] init];
    
    [self.navigationController pushViewController:hexiaoVc animated:YES];
    

}

- (void)rightItemClick
{
    NSLog(@"消息点击");
    SJZHexiaoFailureViewController *hexiaoFailureVc = [[SJZHexiaoFailureViewController alloc] init];
    
    [self.navigationController pushViewController:hexiaoFailureVc animated:YES];
}

/**
 *  初始化模型数据
 */
- (void)setupGroups
{
    
    [self setupGroup0];
    [self setupGroup1];
    [self setupGroup2];

}

- (void)setupGroup0 {
    
    
    // 1.创建组
    SJZCommonGroup *group = [SJZCommonGroup group];
    [self.groups addObject:group];
    // 2.设置所有行
    SJZCommonArrowItem *activityRequest = [SJZCommonArrowItem itemWithTitle:@"活动申请" icon:@"sjz_mine_activity"];
    
    activityRequest.operation = ^{
        NSLog(@"活动申请");
    };
    SJZCommonArrowItem *bossProtocol = [SJZCommonArrowItem itemWithTitle:@"商户协议" icon:@"sjz_mine_bossProtocol"];
    
    bossProtocol.operation = ^{
        NSLog(@"商户协议");
    };
    
    group.items = @[activityRequest,bossProtocol];
    
}

- (void)setupGroup1 {
    
    
    // 1.创建组
    SJZCommonGroup *group = [SJZCommonGroup group];
    [self.groups addObject:group];
  
    SJZCommonArrowItem *feedBack = [SJZCommonArrowItem itemWithTitle:@"意见反馈" icon:@"sjz_mine_feedback"];
    feedBack.operation = ^{
        
    };
    
    group.items = @[feedBack];
    
}

- (void)setupGroup2 {
    
    
    // 1.创建组
    SJZCommonGroup *group = [SJZCommonGroup group];
    [self.groups addObject:group];
    
    SJZCommonArrowItem *setting = [SJZCommonArrowItem itemWithTitle:@"设置" icon:@"sjz_mine_setting"];
    setting.operation = ^{
        SJZSettingController *settingVc = [[SJZSettingController alloc] init];
        
        [self.navigationController pushViewController:settingVc animated:YES];
    };
    
    group.items = @[setting];
    
}

@end
